jQuery(document).ready(function($) {
    var cookie = JSON.parse($.cookie('bjou_school'));
	$.ajax({
		type: 'GET',
		url: 'api/v1/check'

	}).done(function (data, textStatus, jqXHR) {

	}).fail(function (jqXHR, textStatus, errorThrown) {
        window.location = '../index.html';
	});
    $('#welcome').html("欢迎您," + cookie.schoolName)
	$('#logout').on('click', function (event) {
		event.preventDefault();
		$.ajax({
			data: {},
			timeout: 1000,
			type: 'POST',
			url: '../logout'

		}).done(function(data, textStatus, jqXHR) {
			window.location = '../index.html';
		}).fail(function(jqXHR, textStatus, errorThrown) {
		    window.location = '../index.html';
		});
	});


});

var cookie = JSON.parse($.cookie('bjou_school_graduation_details'));
var getGraduationDetailUrl = 'api/v1/graduation/details';
var getGraduationDetailOptions = {
    elem: '#GraduationDetails',
    url:  getGraduationDetailUrl,
    method: 'POST',
    contentType: 'application/json',
    id: 'graduationDetailsTable',
    page: true,
    limit: 20,
    loading: true,
    even: true,
    cols: [[
        {type:'numbers', title:'序号', width: 50, sort: true}
        , {field:'xh', title:'学号'}
        , {field:'xm', title:'姓名'}
        , {field:'bmc', title:'班级名称'}
        , {field:'rxsj', title:'入学时间'}
        , {field:'bysj', title:'毕业时间'}
        , {field:'zymc', title:'专业名称'}
        , {field:'xslbmc', title:'学生类别'}
        , {field:'dzzczh', title:'电子注册号'}
        , {field:'dh', title:'电话'}
    ]],
    request: {
        limitName: 'size'
    },
    response: {
        statusName: null,
        statusCode: null,
        countName: 'totalElements',
        dataName: 'content'
    },
    where: cookie

};
layui.config({
    base: '../layui/plugins/'
})
layui.use(['form', 'table', 'multiSelect', 'element'], function(){
    var $ = layui.jquery
    ,form = layui.form
    ,table = layui.table
    ,element = layui.element
    ,multiSelect = layui.multiSelect;

    table.render(getGraduationDetailOptions);

});
